/*
 * Eugen Stoian <stoian.e@gmail.com> 2010
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "Expression3DFrame.h"
#include "ui_Expression3DFrame.h"
#include "Expression3D.h"
#include "GLWindow.h"

Expression3DFrame::Expression3DFrame(QWidget *parent) :
    QFrame(parent),
    m_ui(new Ui::Expression3DFrame)
{
    m_ui->setupUi(this);
    connect(m_ui->applyButton,SIGNAL(clicked()),m_ui->widget,SLOT(apply()));
    connect(m_ui->revertButton,SIGNAL(clicked()),m_ui->widget,SLOT(revert()));
    connect(m_ui->widget,SIGNAL(modified(bool)),this,SLOT(enableButtons(bool)));
}

Expression3DFrame::~Expression3DFrame()
{
    delete m_ui;
}

bool Expression3DFrame::isModified() const{
    return m_ui->widget->isModified();
}

void Expression3DFrame::apply(){
    m_ui->widget->apply();
}

void Expression3DFrame::revert(){
    m_ui->widget->revert();
}

void Expression3DFrame::changeEvent(QEvent *e)
{
    QFrame::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        m_ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void Expression3DFrame::enableButtons(bool modified){
        m_ui->applyButton->setEnabled(modified);
        m_ui->revertButton->setEnabled(modified);
}

void  Expression3DFrame::setExpression(Expression3D* expr){
    m_ui->widget->setExpression(expr);
}
